package com.easybuilder.game.controller;

import com.easybuilder.common.base.controller.BaseController;
import com.easybuilder.common.exception.BaseException;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/game")
public class GameController extends BaseController {

    @GetMapping("/exception/{type}")
    public Result<?> exception(@PathVariable(name = "type", required = true)Integer type){
        if (type.equals(1)) {
            throw new BaseException(HttpStatus.BAD_REQUEST, "测试自定义异常");
        }
        if (type.equals(2)) {
            throw new RuntimeException("运行时异常");
        }
        return OK("请求成功");
    }

}
